How we can use group by in joining